
user/_alloctest:     file format elf64-littleriscv


Disassembly of section .text:

0000000000000000 <test0>:
#include "kernel/fcntl.h"
#include "kernel/memlayout.h"
#include "user/user.h"

void
test0() {
   0:	715d                	addi	sp,sp,-80
   2:	e486                	sd	ra,72(sp)
   4:	e0a2                	sd	s0,64(sp)
   6:	fc26                	sd	s1,56(sp)
   8:	f84a                	sd	s2,48(sp)
   a:	f44e                	sd	s3,40(sp)
   c:	f052                	sd	s4,32(sp)
   e:	ec56                	sd	s5,24(sp)
  10:	0880                	addi	s0,sp,80
  enum { NCHILD = 50, NFD = 10};
  int i, j;
  int fd;

  printf("filetest: start\n");
  12:	00001517          	auipc	a0,0x1
  16:	a0650513          	addi	a0,a0,-1530 # a18 <malloc+0xec>
  1a:	00001097          	auipc	ra,0x1
  1e:	852080e7          	jalr	-1966(ra) # 86c <printf>
  22:	03200493          	li	s1,50
    printf("test setup is wrong\n");
    exit(1);
  }

  for (i = 0; i < NCHILD; i++) {
    int pid = fork();
  26:	00000097          	auipc	ra,0x0
  2a:	4be080e7          	jalr	1214(ra) # 4e4 <fork>
    if(pid < 0){
  2e:	00054f63          	bltz	a0,4c <test0+0x4c>
      printf("fork failed");
      exit(1);
    }
    if(pid == 0){
  32:	c915                	beqz	a0,66 <test0+0x66>
  for (i = 0; i < NCHILD; i++) {
  34:	34fd                	addiw	s1,s1,-1
  36:	f8e5                	bnez	s1,26 <test0+0x26>
  38:	03200493          	li	s1,50
      sleep(10);
      exit(0);  // no errors; exit with 0.
    }
  }

  int all_ok = 1;
  3c:	4905                	li	s2,1
  for(int i = 0; i < NCHILD; i++){
    int xstatus;
    wait(&xstatus);
    if(xstatus != 0) {
      if(all_ok == 1)
  3e:	4985                	li	s3,1
        printf("filetest: FAILED\n");
  40:	00001a97          	auipc	s5,0x1
  44:	a08a8a93          	addi	s5,s5,-1528 # a48 <malloc+0x11c>
      all_ok = 0;
  48:	4a01                	li	s4,0
  4a:	a0a5                	j	b2 <test0+0xb2>
      printf("fork failed");
  4c:	00001517          	auipc	a0,0x1
  50:	9e450513          	addi	a0,a0,-1564 # a30 <malloc+0x104>
  54:	00001097          	auipc	ra,0x1
  58:	818080e7          	jalr	-2024(ra) # 86c <printf>
      exit(1);
  5c:	4505                	li	a0,1
  5e:	00000097          	auipc	ra,0x0
  62:	48e080e7          	jalr	1166(ra) # 4ec <exit>
  66:	44a9                	li	s1,10
        if ((fd = open("README", O_RDONLY)) < 0) {
  68:	00001917          	auipc	s2,0x1
  6c:	9d890913          	addi	s2,s2,-1576 # a40 <malloc+0x114>
  70:	4581                	li	a1,0
  72:	854a                	mv	a0,s2
  74:	00000097          	auipc	ra,0x0
  78:	4b8080e7          	jalr	1208(ra) # 52c <open>
  7c:	00054e63          	bltz	a0,98 <test0+0x98>
      for(j = 0; j < NFD; j++) {
  80:	34fd                	addiw	s1,s1,-1
  82:	f4fd                	bnez	s1,70 <test0+0x70>
      sleep(10);
  84:	4529                	li	a0,10
  86:	00000097          	auipc	ra,0x0
  8a:	4f6080e7          	jalr	1270(ra) # 57c <sleep>
      exit(0);  // no errors; exit with 0.
  8e:	4501                	li	a0,0
  90:	00000097          	auipc	ra,0x0
  94:	45c080e7          	jalr	1116(ra) # 4ec <exit>
          exit(1);
  98:	4505                	li	a0,1
  9a:	00000097          	auipc	ra,0x0
  9e:	452080e7          	jalr	1106(ra) # 4ec <exit>
        printf("filetest: FAILED\n");
  a2:	8556                	mv	a0,s5
  a4:	00000097          	auipc	ra,0x0
  a8:	7c8080e7          	jalr	1992(ra) # 86c <printf>
      all_ok = 0;
  ac:	8952                	mv	s2,s4
  for(int i = 0; i < NCHILD; i++){
  ae:	34fd                	addiw	s1,s1,-1
  b0:	cc89                	beqz	s1,ca <test0+0xca>
    wait(&xstatus);
  b2:	fbc40513          	addi	a0,s0,-68
  b6:	00000097          	auipc	ra,0x0
  ba:	43e080e7          	jalr	1086(ra) # 4f4 <wait>
    if(xstatus != 0) {
  be:	fbc42783          	lw	a5,-68(s0)
  c2:	d7f5                	beqz	a5,ae <test0+0xae>
      if(all_ok == 1)
  c4:	ff3915e3          	bne	s2,s3,ae <test0+0xae>
  c8:	bfe9                	j	a2 <test0+0xa2>
    }
  }

  if(all_ok)
  ca:	00091b63          	bnez	s2,e0 <test0+0xe0>
    printf("filetest: OK\n");
}
  ce:	60a6                	ld	ra,72(sp)
  d0:	6406                	ld	s0,64(sp)
  d2:	74e2                	ld	s1,56(sp)
  d4:	7942                	ld	s2,48(sp)
  d6:	79a2                	ld	s3,40(sp)
  d8:	7a02                	ld	s4,32(sp)
  da:	6ae2                	ld	s5,24(sp)
  dc:	6161                	addi	sp,sp,80
  de:	8082                	ret
    printf("filetest: OK\n");
  e0:	00001517          	auipc	a0,0x1
  e4:	98050513          	addi	a0,a0,-1664 # a60 <malloc+0x134>
  e8:	00000097          	auipc	ra,0x0
  ec:	784080e7          	jalr	1924(ra) # 86c <printf>
}
  f0:	bff9                	j	ce <test0+0xce>

00000000000000f2 <test1>:

// Allocate all free memory and count how it is
void test1()
{
  f2:	7139                	addi	sp,sp,-64
  f4:	fc06                	sd	ra,56(sp)
  f6:	f822                	sd	s0,48(sp)
  f8:	f426                	sd	s1,40(sp)
  fa:	f04a                	sd	s2,32(sp)
  fc:	ec4e                	sd	s3,24(sp)
  fe:	0080                	addi	s0,sp,64
  void *a;
  int tot = 0;
  char buf[1];
  int fds[2];
  
  printf("memtest: start\n");  
 100:	00001517          	auipc	a0,0x1
 104:	97050513          	addi	a0,a0,-1680 # a70 <malloc+0x144>
 108:	00000097          	auipc	ra,0x0
 10c:	764080e7          	jalr	1892(ra) # 86c <printf>
  if(pipe(fds) != 0){
 110:	fc040513          	addi	a0,s0,-64
 114:	00000097          	auipc	ra,0x0
 118:	3e8080e7          	jalr	1000(ra) # 4fc <pipe>
 11c:	e535                	bnez	a0,188 <test1+0x96>
 11e:	84aa                	mv	s1,a0
    printf("pipe() failed\n");
    exit(1);
  }
  int pid = fork();
 120:	00000097          	auipc	ra,0x0
 124:	3c4080e7          	jalr	964(ra) # 4e4 <fork>
  if(pid < 0){
 128:	06054d63          	bltz	a0,1a2 <test1+0xb0>
    printf("fork failed");
    exit(1);
  }
  if(pid == 0){
 12c:	ed49                	bnez	a0,1c6 <test1+0xd4>
      close(fds[0]);
 12e:	fc042503          	lw	a0,-64(s0)
 132:	00000097          	auipc	ra,0x0
 136:	3e2080e7          	jalr	994(ra) # 514 <close>
      while(1) {
        a = sbrk(PGSIZE);
        if (a == (char*)0xffffffffffffffffL)
 13a:	54fd                	li	s1,-1
          exit(0);
        *(int *)(a+4) = 1;
 13c:	4985                	li	s3,1
        if (write(fds[1], "x", 1) != 1) {
 13e:	00001917          	auipc	s2,0x1
 142:	95290913          	addi	s2,s2,-1710 # a90 <malloc+0x164>
        a = sbrk(PGSIZE);
 146:	6505                	lui	a0,0x1
 148:	00000097          	auipc	ra,0x0
 14c:	42c080e7          	jalr	1068(ra) # 574 <sbrk>
        if (a == (char*)0xffffffffffffffffL)
 150:	06950663          	beq	a0,s1,1bc <test1+0xca>
        *(int *)(a+4) = 1;
 154:	01352223          	sw	s3,4(a0) # 1004 <_end+0x4c4>
        if (write(fds[1], "x", 1) != 1) {
 158:	4605                	li	a2,1
 15a:	85ca                	mv	a1,s2
 15c:	fc442503          	lw	a0,-60(s0)
 160:	00000097          	auipc	ra,0x0
 164:	3ac080e7          	jalr	940(ra) # 50c <write>
 168:	4785                	li	a5,1
 16a:	fcf50ee3          	beq	a0,a5,146 <test1+0x54>
          printf("write failed");
 16e:	00001517          	auipc	a0,0x1
 172:	92a50513          	addi	a0,a0,-1750 # a98 <malloc+0x16c>
 176:	00000097          	auipc	ra,0x0
 17a:	6f6080e7          	jalr	1782(ra) # 86c <printf>
          exit(1);
 17e:	4505                	li	a0,1
 180:	00000097          	auipc	ra,0x0
 184:	36c080e7          	jalr	876(ra) # 4ec <exit>
    printf("pipe() failed\n");
 188:	00001517          	auipc	a0,0x1
 18c:	8f850513          	addi	a0,a0,-1800 # a80 <malloc+0x154>
 190:	00000097          	auipc	ra,0x0
 194:	6dc080e7          	jalr	1756(ra) # 86c <printf>
    exit(1);
 198:	4505                	li	a0,1
 19a:	00000097          	auipc	ra,0x0
 19e:	352080e7          	jalr	850(ra) # 4ec <exit>
    printf("fork failed");
 1a2:	00001517          	auipc	a0,0x1
 1a6:	88e50513          	addi	a0,a0,-1906 # a30 <malloc+0x104>
 1aa:	00000097          	auipc	ra,0x0
 1ae:	6c2080e7          	jalr	1730(ra) # 86c <printf>
    exit(1);
 1b2:	4505                	li	a0,1
 1b4:	00000097          	auipc	ra,0x0
 1b8:	338080e7          	jalr	824(ra) # 4ec <exit>
          exit(0);
 1bc:	4501                	li	a0,0
 1be:	00000097          	auipc	ra,0x0
 1c2:	32e080e7          	jalr	814(ra) # 4ec <exit>
        }
      }
      exit(0);
  }
  close(fds[1]);
 1c6:	fc442503          	lw	a0,-60(s0)
 1ca:	00000097          	auipc	ra,0x0
 1ce:	34a080e7          	jalr	842(ra) # 514 <close>
  while(1) {
      if (read(fds[0], buf, 1) != 1) {
 1d2:	4605                	li	a2,1
 1d4:	fc840593          	addi	a1,s0,-56
 1d8:	fc042503          	lw	a0,-64(s0)
 1dc:	00000097          	auipc	ra,0x0
 1e0:	328080e7          	jalr	808(ra) # 504 <read>
 1e4:	4785                	li	a5,1
 1e6:	00f51463          	bne	a0,a5,1ee <test1+0xfc>
        break;
      } else {
        tot += 1;
 1ea:	2485                	addiw	s1,s1,1
      if (read(fds[0], buf, 1) != 1) {
 1ec:	b7dd                	j	1d2 <test1+0xe0>
      }
  }
  //int n = (PHYSTOP-KERNBASE)/PGSIZE;
  //printf("allocated %d out of %d pages\n", tot, n);
  if(tot < 31950) {
 1ee:	67a1                	lui	a5,0x8
 1f0:	ccd78793          	addi	a5,a5,-819 # 7ccd <__global_pointer$+0x69a5>
 1f4:	0297ca63          	blt	a5,s1,228 <test1+0x136>
    printf("expected to allocate at least 31950, only got %d\n", tot);
 1f8:	85a6                	mv	a1,s1
 1fa:	00001517          	auipc	a0,0x1
 1fe:	8ae50513          	addi	a0,a0,-1874 # aa8 <malloc+0x17c>
 202:	00000097          	auipc	ra,0x0
 206:	66a080e7          	jalr	1642(ra) # 86c <printf>
    printf("memtest: FAILED\n");  
 20a:	00001517          	auipc	a0,0x1
 20e:	8d650513          	addi	a0,a0,-1834 # ae0 <malloc+0x1b4>
 212:	00000097          	auipc	ra,0x0
 216:	65a080e7          	jalr	1626(ra) # 86c <printf>
  } else {
    printf("memtest: OK\n");  
  }
}
 21a:	70e2                	ld	ra,56(sp)
 21c:	7442                	ld	s0,48(sp)
 21e:	74a2                	ld	s1,40(sp)
 220:	7902                	ld	s2,32(sp)
 222:	69e2                	ld	s3,24(sp)
 224:	6121                	addi	sp,sp,64
 226:	8082                	ret
    printf("memtest: OK\n");  
 228:	00001517          	auipc	a0,0x1
 22c:	8d050513          	addi	a0,a0,-1840 # af8 <malloc+0x1cc>
 230:	00000097          	auipc	ra,0x0
 234:	63c080e7          	jalr	1596(ra) # 86c <printf>
}
 238:	b7cd                	j	21a <test1+0x128>

000000000000023a <main>:

int
main(int argc, char *argv[])
{
 23a:	1141                	addi	sp,sp,-16
 23c:	e406                	sd	ra,8(sp)
 23e:	e022                	sd	s0,0(sp)
 240:	0800                	addi	s0,sp,16
  test0();
 242:	00000097          	auipc	ra,0x0
 246:	dbe080e7          	jalr	-578(ra) # 0 <test0>
  test1();
 24a:	00000097          	auipc	ra,0x0
 24e:	ea8080e7          	jalr	-344(ra) # f2 <test1>
  exit(0);
 252:	4501                	li	a0,0
 254:	00000097          	auipc	ra,0x0
 258:	298080e7          	jalr	664(ra) # 4ec <exit>

000000000000025c <strcpy>:
#include "kernel/fcntl.h"
#include "user/user.h"

char*
strcpy(char *s, const char *t)
{
 25c:	1141                	addi	sp,sp,-16
 25e:	e422                	sd	s0,8(sp)
 260:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 262:	87aa                	mv	a5,a0
 264:	0585                	addi	a1,a1,1
 266:	0785                	addi	a5,a5,1
 268:	fff5c703          	lbu	a4,-1(a1)
 26c:	fee78fa3          	sb	a4,-1(a5)
 270:	fb75                	bnez	a4,264 <strcpy+0x8>
    ;
  return os;
}
 272:	6422                	ld	s0,8(sp)
 274:	0141                	addi	sp,sp,16
 276:	8082                	ret

0000000000000278 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 278:	1141                	addi	sp,sp,-16
 27a:	e422                	sd	s0,8(sp)
 27c:	0800                	addi	s0,sp,16
  while(*p && *p == *q)
 27e:	00054783          	lbu	a5,0(a0)
 282:	cf91                	beqz	a5,29e <strcmp+0x26>
 284:	0005c703          	lbu	a4,0(a1)
 288:	00f71b63          	bne	a4,a5,29e <strcmp+0x26>
    p++, q++;
 28c:	0505                	addi	a0,a0,1
 28e:	0585                	addi	a1,a1,1
  while(*p && *p == *q)
 290:	00054783          	lbu	a5,0(a0)
 294:	c789                	beqz	a5,29e <strcmp+0x26>
 296:	0005c703          	lbu	a4,0(a1)
 29a:	fef709e3          	beq	a4,a5,28c <strcmp+0x14>
  return (uchar)*p - (uchar)*q;
 29e:	0005c503          	lbu	a0,0(a1)
}
 2a2:	40a7853b          	subw	a0,a5,a0
 2a6:	6422                	ld	s0,8(sp)
 2a8:	0141                	addi	sp,sp,16
 2aa:	8082                	ret

00000000000002ac <strlen>:

uint
strlen(const char *s)
{
 2ac:	1141                	addi	sp,sp,-16
 2ae:	e422                	sd	s0,8(sp)
 2b0:	0800                	addi	s0,sp,16
  int n;

  for(n = 0; s[n]; n++)
 2b2:	00054783          	lbu	a5,0(a0)
 2b6:	cf91                	beqz	a5,2d2 <strlen+0x26>
 2b8:	0505                	addi	a0,a0,1
 2ba:	87aa                	mv	a5,a0
 2bc:	4685                	li	a3,1
 2be:	9e89                	subw	a3,a3,a0
 2c0:	00f6853b          	addw	a0,a3,a5
 2c4:	0785                	addi	a5,a5,1
 2c6:	fff7c703          	lbu	a4,-1(a5)
 2ca:	fb7d                	bnez	a4,2c0 <strlen+0x14>
    ;
  return n;
}
 2cc:	6422                	ld	s0,8(sp)
 2ce:	0141                	addi	sp,sp,16
 2d0:	8082                	ret
  for(n = 0; s[n]; n++)
 2d2:	4501                	li	a0,0
 2d4:	bfe5                	j	2cc <strlen+0x20>

00000000000002d6 <memset>:

void*
memset(void *dst, int c, uint n)
{
 2d6:	1141                	addi	sp,sp,-16
 2d8:	e422                	sd	s0,8(sp)
 2da:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
 2dc:	ce09                	beqz	a2,2f6 <memset+0x20>
 2de:	87aa                	mv	a5,a0
 2e0:	fff6071b          	addiw	a4,a2,-1
 2e4:	1702                	slli	a4,a4,0x20
 2e6:	9301                	srli	a4,a4,0x20
 2e8:	0705                	addi	a4,a4,1
 2ea:	972a                	add	a4,a4,a0
    cdst[i] = c;
 2ec:	00b78023          	sb	a1,0(a5)
  for(i = 0; i < n; i++){
 2f0:	0785                	addi	a5,a5,1
 2f2:	fee79de3          	bne	a5,a4,2ec <memset+0x16>
  }
  return dst;
}
 2f6:	6422                	ld	s0,8(sp)
 2f8:	0141                	addi	sp,sp,16
 2fa:	8082                	ret

00000000000002fc <strchr>:

char*
strchr(const char *s, char c)
{
 2fc:	1141                	addi	sp,sp,-16
 2fe:	e422                	sd	s0,8(sp)
 300:	0800                	addi	s0,sp,16
  for(; *s; s++)
 302:	00054783          	lbu	a5,0(a0)
 306:	cf91                	beqz	a5,322 <strchr+0x26>
    if(*s == c)
 308:	00f58a63          	beq	a1,a5,31c <strchr+0x20>
  for(; *s; s++)
 30c:	0505                	addi	a0,a0,1
 30e:	00054783          	lbu	a5,0(a0)
 312:	c781                	beqz	a5,31a <strchr+0x1e>
    if(*s == c)
 314:	feb79ce3          	bne	a5,a1,30c <strchr+0x10>
 318:	a011                	j	31c <strchr+0x20>
      return (char*)s;
  return 0;
 31a:	4501                	li	a0,0
}
 31c:	6422                	ld	s0,8(sp)
 31e:	0141                	addi	sp,sp,16
 320:	8082                	ret
  return 0;
 322:	4501                	li	a0,0
 324:	bfe5                	j	31c <strchr+0x20>

0000000000000326 <gets>:

char*
gets(char *buf, int max)
{
 326:	711d                	addi	sp,sp,-96
 328:	ec86                	sd	ra,88(sp)
 32a:	e8a2                	sd	s0,80(sp)
 32c:	e4a6                	sd	s1,72(sp)
 32e:	e0ca                	sd	s2,64(sp)
 330:	fc4e                	sd	s3,56(sp)
 332:	f852                	sd	s4,48(sp)
 334:	f456                	sd	s5,40(sp)
 336:	f05a                	sd	s6,32(sp)
 338:	ec5e                	sd	s7,24(sp)
 33a:	1080                	addi	s0,sp,96
 33c:	8baa                	mv	s7,a0
 33e:	8a2e                	mv	s4,a1
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 340:	892a                	mv	s2,a0
 342:	4981                	li	s3,0
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
 344:	4aa9                	li	s5,10
 346:	4b35                	li	s6,13
  for(i=0; i+1 < max; ){
 348:	0019849b          	addiw	s1,s3,1
 34c:	0344d863          	ble	s4,s1,37c <gets+0x56>
    cc = read(0, &c, 1);
 350:	4605                	li	a2,1
 352:	faf40593          	addi	a1,s0,-81
 356:	4501                	li	a0,0
 358:	00000097          	auipc	ra,0x0
 35c:	1ac080e7          	jalr	428(ra) # 504 <read>
    if(cc < 1)
 360:	00a05e63          	blez	a0,37c <gets+0x56>
    buf[i++] = c;
 364:	faf44783          	lbu	a5,-81(s0)
 368:	00f90023          	sb	a5,0(s2)
    if(c == '\n' || c == '\r')
 36c:	01578763          	beq	a5,s5,37a <gets+0x54>
 370:	0905                	addi	s2,s2,1
  for(i=0; i+1 < max; ){
 372:	89a6                	mv	s3,s1
    if(c == '\n' || c == '\r')
 374:	fd679ae3          	bne	a5,s6,348 <gets+0x22>
 378:	a011                	j	37c <gets+0x56>
  for(i=0; i+1 < max; ){
 37a:	89a6                	mv	s3,s1
      break;
  }
  buf[i] = '\0';
 37c:	99de                	add	s3,s3,s7
 37e:	00098023          	sb	zero,0(s3)
  return buf;
}
 382:	855e                	mv	a0,s7
 384:	60e6                	ld	ra,88(sp)
 386:	6446                	ld	s0,80(sp)
 388:	64a6                	ld	s1,72(sp)
 38a:	6906                	ld	s2,64(sp)
 38c:	79e2                	ld	s3,56(sp)
 38e:	7a42                	ld	s4,48(sp)
 390:	7aa2                	ld	s5,40(sp)
 392:	7b02                	ld	s6,32(sp)
 394:	6be2                	ld	s7,24(sp)
 396:	6125                	addi	sp,sp,96
 398:	8082                	ret

000000000000039a <stat>:

int
stat(const char *n, struct stat *st)
{
 39a:	1101                	addi	sp,sp,-32
 39c:	ec06                	sd	ra,24(sp)
 39e:	e822                	sd	s0,16(sp)
 3a0:	e426                	sd	s1,8(sp)
 3a2:	e04a                	sd	s2,0(sp)
 3a4:	1000                	addi	s0,sp,32
 3a6:	892e                	mv	s2,a1
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 3a8:	4581                	li	a1,0
 3aa:	00000097          	auipc	ra,0x0
 3ae:	182080e7          	jalr	386(ra) # 52c <open>
  if(fd < 0)
 3b2:	02054563          	bltz	a0,3dc <stat+0x42>
 3b6:	84aa                	mv	s1,a0
    return -1;
  r = fstat(fd, st);
 3b8:	85ca                	mv	a1,s2
 3ba:	00000097          	auipc	ra,0x0
 3be:	18a080e7          	jalr	394(ra) # 544 <fstat>
 3c2:	892a                	mv	s2,a0
  close(fd);
 3c4:	8526                	mv	a0,s1
 3c6:	00000097          	auipc	ra,0x0
 3ca:	14e080e7          	jalr	334(ra) # 514 <close>
  return r;
}
 3ce:	854a                	mv	a0,s2
 3d0:	60e2                	ld	ra,24(sp)
 3d2:	6442                	ld	s0,16(sp)
 3d4:	64a2                	ld	s1,8(sp)
 3d6:	6902                	ld	s2,0(sp)
 3d8:	6105                	addi	sp,sp,32
 3da:	8082                	ret
    return -1;
 3dc:	597d                	li	s2,-1
 3de:	bfc5                	j	3ce <stat+0x34>

00000000000003e0 <atoi>:

int
atoi(const char *s)
{
 3e0:	1141                	addi	sp,sp,-16
 3e2:	e422                	sd	s0,8(sp)
 3e4:	0800                	addi	s0,sp,16
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 3e6:	00054683          	lbu	a3,0(a0)
 3ea:	fd06879b          	addiw	a5,a3,-48
 3ee:	0ff7f793          	andi	a5,a5,255
 3f2:	4725                	li	a4,9
 3f4:	02f76963          	bltu	a4,a5,426 <atoi+0x46>
 3f8:	862a                	mv	a2,a0
  n = 0;
 3fa:	4501                	li	a0,0
  while('0' <= *s && *s <= '9')
 3fc:	45a5                	li	a1,9
    n = n*10 + *s++ - '0';
 3fe:	0605                	addi	a2,a2,1
 400:	0025179b          	slliw	a5,a0,0x2
 404:	9fa9                	addw	a5,a5,a0
 406:	0017979b          	slliw	a5,a5,0x1
 40a:	9fb5                	addw	a5,a5,a3
 40c:	fd07851b          	addiw	a0,a5,-48
  while('0' <= *s && *s <= '9')
 410:	00064683          	lbu	a3,0(a2)
 414:	fd06871b          	addiw	a4,a3,-48
 418:	0ff77713          	andi	a4,a4,255
 41c:	fee5f1e3          	bleu	a4,a1,3fe <atoi+0x1e>
  return n;
}
 420:	6422                	ld	s0,8(sp)
 422:	0141                	addi	sp,sp,16
 424:	8082                	ret
  n = 0;
 426:	4501                	li	a0,0
 428:	bfe5                	j	420 <atoi+0x40>

000000000000042a <memmove>:

void*
memmove(void *vdst, const void *vsrc, int n)
{
 42a:	1141                	addi	sp,sp,-16
 42c:	e422                	sd	s0,8(sp)
 42e:	0800                	addi	s0,sp,16
  char *dst;
  const char *src;

  dst = vdst;
  src = vsrc;
  if (src > dst) {
 430:	02b57663          	bleu	a1,a0,45c <memmove+0x32>
    while(n-- > 0)
 434:	02c05163          	blez	a2,456 <memmove+0x2c>
 438:	fff6079b          	addiw	a5,a2,-1
 43c:	1782                	slli	a5,a5,0x20
 43e:	9381                	srli	a5,a5,0x20
 440:	0785                	addi	a5,a5,1
 442:	97aa                	add	a5,a5,a0
  dst = vdst;
 444:	872a                	mv	a4,a0
      *dst++ = *src++;
 446:	0585                	addi	a1,a1,1
 448:	0705                	addi	a4,a4,1
 44a:	fff5c683          	lbu	a3,-1(a1)
 44e:	fed70fa3          	sb	a3,-1(a4)
    while(n-- > 0)
 452:	fee79ae3          	bne	a5,a4,446 <memmove+0x1c>
    src += n;
    while(n-- > 0)
      *--dst = *--src;
  }
  return vdst;
}
 456:	6422                	ld	s0,8(sp)
 458:	0141                	addi	sp,sp,16
 45a:	8082                	ret
    dst += n;
 45c:	00c50733          	add	a4,a0,a2
    src += n;
 460:	95b2                	add	a1,a1,a2
    while(n-- > 0)
 462:	fec05ae3          	blez	a2,456 <memmove+0x2c>
 466:	fff6079b          	addiw	a5,a2,-1
 46a:	1782                	slli	a5,a5,0x20
 46c:	9381                	srli	a5,a5,0x20
 46e:	fff7c793          	not	a5,a5
 472:	97ba                	add	a5,a5,a4
      *--dst = *--src;
 474:	15fd                	addi	a1,a1,-1
 476:	177d                	addi	a4,a4,-1
 478:	0005c683          	lbu	a3,0(a1)
 47c:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
 480:	fef71ae3          	bne	a4,a5,474 <memmove+0x4a>
 484:	bfc9                	j	456 <memmove+0x2c>

0000000000000486 <memcmp>:

int
memcmp(const void *s1, const void *s2, uint n)
{
 486:	1141                	addi	sp,sp,-16
 488:	e422                	sd	s0,8(sp)
 48a:	0800                	addi	s0,sp,16
  const char *p1 = s1, *p2 = s2;
  while (n-- > 0) {
 48c:	ce15                	beqz	a2,4c8 <memcmp+0x42>
 48e:	fff6069b          	addiw	a3,a2,-1
    if (*p1 != *p2) {
 492:	00054783          	lbu	a5,0(a0)
 496:	0005c703          	lbu	a4,0(a1)
 49a:	02e79063          	bne	a5,a4,4ba <memcmp+0x34>
 49e:	1682                	slli	a3,a3,0x20
 4a0:	9281                	srli	a3,a3,0x20
 4a2:	0685                	addi	a3,a3,1
 4a4:	96aa                	add	a3,a3,a0
      return *p1 - *p2;
    }
    p1++;
 4a6:	0505                	addi	a0,a0,1
    p2++;
 4a8:	0585                	addi	a1,a1,1
  while (n-- > 0) {
 4aa:	00d50d63          	beq	a0,a3,4c4 <memcmp+0x3e>
    if (*p1 != *p2) {
 4ae:	00054783          	lbu	a5,0(a0)
 4b2:	0005c703          	lbu	a4,0(a1)
 4b6:	fee788e3          	beq	a5,a4,4a6 <memcmp+0x20>
      return *p1 - *p2;
 4ba:	40e7853b          	subw	a0,a5,a4
  }
  return 0;
}
 4be:	6422                	ld	s0,8(sp)
 4c0:	0141                	addi	sp,sp,16
 4c2:	8082                	ret
  return 0;
 4c4:	4501                	li	a0,0
 4c6:	bfe5                	j	4be <memcmp+0x38>
 4c8:	4501                	li	a0,0
 4ca:	bfd5                	j	4be <memcmp+0x38>

00000000000004cc <memcpy>:

void *
memcpy(void *dst, const void *src, uint n)
{
 4cc:	1141                	addi	sp,sp,-16
 4ce:	e406                	sd	ra,8(sp)
 4d0:	e022                	sd	s0,0(sp)
 4d2:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
 4d4:	00000097          	auipc	ra,0x0
 4d8:	f56080e7          	jalr	-170(ra) # 42a <memmove>
}
 4dc:	60a2                	ld	ra,8(sp)
 4de:	6402                	ld	s0,0(sp)
 4e0:	0141                	addi	sp,sp,16
 4e2:	8082                	ret

00000000000004e4 <fork>:
# generated by usys.pl - do not edit
#include "kernel/syscall.h"
.global fork
fork:
 li a7, SYS_fork
 4e4:	4885                	li	a7,1
 ecall
 4e6:	00000073          	ecall
 ret
 4ea:	8082                	ret

00000000000004ec <exit>:
.global exit
exit:
 li a7, SYS_exit
 4ec:	4889                	li	a7,2
 ecall
 4ee:	00000073          	ecall
 ret
 4f2:	8082                	ret

00000000000004f4 <wait>:
.global wait
wait:
 li a7, SYS_wait
 4f4:	488d                	li	a7,3
 ecall
 4f6:	00000073          	ecall
 ret
 4fa:	8082                	ret

00000000000004fc <pipe>:
.global pipe
pipe:
 li a7, SYS_pipe
 4fc:	4891                	li	a7,4
 ecall
 4fe:	00000073          	ecall
 ret
 502:	8082                	ret

0000000000000504 <read>:
.global read
read:
 li a7, SYS_read
 504:	4895                	li	a7,5
 ecall
 506:	00000073          	ecall
 ret
 50a:	8082                	ret

000000000000050c <write>:
.global write
write:
 li a7, SYS_write
 50c:	48c1                	li	a7,16
 ecall
 50e:	00000073          	ecall
 ret
 512:	8082                	ret

0000000000000514 <close>:
.global close
close:
 li a7, SYS_close
 514:	48d5                	li	a7,21
 ecall
 516:	00000073          	ecall
 ret
 51a:	8082                	ret

000000000000051c <kill>:
.global kill
kill:
 li a7, SYS_kill
 51c:	4899                	li	a7,6
 ecall
 51e:	00000073          	ecall
 ret
 522:	8082                	ret

0000000000000524 <exec>:
.global exec
exec:
 li a7, SYS_exec
 524:	489d                	li	a7,7
 ecall
 526:	00000073          	ecall
 ret
 52a:	8082                	ret

000000000000052c <open>:
.global open
open:
 li a7, SYS_open
 52c:	48bd                	li	a7,15
 ecall
 52e:	00000073          	ecall
 ret
 532:	8082                	ret

0000000000000534 <mknod>:
.global mknod
mknod:
 li a7, SYS_mknod
 534:	48c5                	li	a7,17
 ecall
 536:	00000073          	ecall
 ret
 53a:	8082                	ret

000000000000053c <unlink>:
.global unlink
unlink:
 li a7, SYS_unlink
 53c:	48c9                	li	a7,18
 ecall
 53e:	00000073          	ecall
 ret
 542:	8082                	ret

0000000000000544 <fstat>:
.global fstat
fstat:
 li a7, SYS_fstat
 544:	48a1                	li	a7,8
 ecall
 546:	00000073          	ecall
 ret
 54a:	8082                	ret

000000000000054c <link>:
.global link
link:
 li a7, SYS_link
 54c:	48cd                	li	a7,19
 ecall
 54e:	00000073          	ecall
 ret
 552:	8082                	ret

0000000000000554 <mkdir>:
.global mkdir
mkdir:
 li a7, SYS_mkdir
 554:	48d1                	li	a7,20
 ecall
 556:	00000073          	ecall
 ret
 55a:	8082                	ret

000000000000055c <chdir>:
.global chdir
chdir:
 li a7, SYS_chdir
 55c:	48a5                	li	a7,9
 ecall
 55e:	00000073          	ecall
 ret
 562:	8082                	ret

0000000000000564 <dup>:
.global dup
dup:
 li a7, SYS_dup
 564:	48a9                	li	a7,10
 ecall
 566:	00000073          	ecall
 ret
 56a:	8082                	ret

000000000000056c <getpid>:
.global getpid
getpid:
 li a7, SYS_getpid
 56c:	48ad                	li	a7,11
 ecall
 56e:	00000073          	ecall
 ret
 572:	8082                	ret

0000000000000574 <sbrk>:
.global sbrk
sbrk:
 li a7, SYS_sbrk
 574:	48b1                	li	a7,12
 ecall
 576:	00000073          	ecall
 ret
 57a:	8082                	ret

000000000000057c <sleep>:
.global sleep
sleep:
 li a7, SYS_sleep
 57c:	48b5                	li	a7,13
 ecall
 57e:	00000073          	ecall
 ret
 582:	8082                	ret

0000000000000584 <uptime>:
.global uptime
uptime:
 li a7, SYS_uptime
 584:	48b9                	li	a7,14
 ecall
 586:	00000073          	ecall
 ret
 58a:	8082                	ret

000000000000058c <ntas>:
.global ntas
ntas:
 li a7, SYS_ntas
 58c:	48d9                	li	a7,22
 ecall
 58e:	00000073          	ecall
 ret
 592:	8082                	ret

0000000000000594 <putc>:

static char digits[] = "0123456789ABCDEF";

static void
putc(int fd, char c)
{
 594:	1101                	addi	sp,sp,-32
 596:	ec06                	sd	ra,24(sp)
 598:	e822                	sd	s0,16(sp)
 59a:	1000                	addi	s0,sp,32
 59c:	feb407a3          	sb	a1,-17(s0)
  write(fd, &c, 1);
 5a0:	4605                	li	a2,1
 5a2:	fef40593          	addi	a1,s0,-17
 5a6:	00000097          	auipc	ra,0x0
 5aa:	f66080e7          	jalr	-154(ra) # 50c <write>
}
 5ae:	60e2                	ld	ra,24(sp)
 5b0:	6442                	ld	s0,16(sp)
 5b2:	6105                	addi	sp,sp,32
 5b4:	8082                	ret

00000000000005b6 <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 5b6:	7139                	addi	sp,sp,-64
 5b8:	fc06                	sd	ra,56(sp)
 5ba:	f822                	sd	s0,48(sp)
 5bc:	f426                	sd	s1,40(sp)
 5be:	f04a                	sd	s2,32(sp)
 5c0:	ec4e                	sd	s3,24(sp)
 5c2:	0080                	addi	s0,sp,64
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
 5c4:	c299                	beqz	a3,5ca <printint+0x14>
 5c6:	0005cd63          	bltz	a1,5e0 <printint+0x2a>
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 5ca:	2581                	sext.w	a1,a1
  neg = 0;
 5cc:	4301                	li	t1,0
 5ce:	fc040713          	addi	a4,s0,-64
  }

  i = 0;
 5d2:	4801                	li	a6,0
  do{
    buf[i++] = digits[x % base];
 5d4:	2601                	sext.w	a2,a2
 5d6:	00000897          	auipc	a7,0x0
 5da:	53288893          	addi	a7,a7,1330 # b08 <digits>
 5de:	a801                	j	5ee <printint+0x38>
    x = -xx;
 5e0:	40b005bb          	negw	a1,a1
 5e4:	2581                	sext.w	a1,a1
    neg = 1;
 5e6:	4305                	li	t1,1
    x = -xx;
 5e8:	b7dd                	j	5ce <printint+0x18>
  }while((x /= base) != 0);
 5ea:	85be                	mv	a1,a5
    buf[i++] = digits[x % base];
 5ec:	8836                	mv	a6,a3
 5ee:	0018069b          	addiw	a3,a6,1
 5f2:	02c5f7bb          	remuw	a5,a1,a2
 5f6:	1782                	slli	a5,a5,0x20
 5f8:	9381                	srli	a5,a5,0x20
 5fa:	97c6                	add	a5,a5,a7
 5fc:	0007c783          	lbu	a5,0(a5)
 600:	00f70023          	sb	a5,0(a4)
  }while((x /= base) != 0);
 604:	0705                	addi	a4,a4,1
 606:	02c5d7bb          	divuw	a5,a1,a2
 60a:	fec5f0e3          	bleu	a2,a1,5ea <printint+0x34>
  if(neg)
 60e:	00030b63          	beqz	t1,624 <printint+0x6e>
    buf[i++] = '-';
 612:	fd040793          	addi	a5,s0,-48
 616:	96be                	add	a3,a3,a5
 618:	02d00793          	li	a5,45
 61c:	fef68823          	sb	a5,-16(a3)
 620:	0028069b          	addiw	a3,a6,2

  while(--i >= 0)
 624:	02d05963          	blez	a3,656 <printint+0xa0>
 628:	89aa                	mv	s3,a0
 62a:	fc040793          	addi	a5,s0,-64
 62e:	00d784b3          	add	s1,a5,a3
 632:	fff78913          	addi	s2,a5,-1
 636:	9936                	add	s2,s2,a3
 638:	36fd                	addiw	a3,a3,-1
 63a:	1682                	slli	a3,a3,0x20
 63c:	9281                	srli	a3,a3,0x20
 63e:	40d90933          	sub	s2,s2,a3
    putc(fd, buf[i]);
 642:	fff4c583          	lbu	a1,-1(s1)
 646:	854e                	mv	a0,s3
 648:	00000097          	auipc	ra,0x0
 64c:	f4c080e7          	jalr	-180(ra) # 594 <putc>
  while(--i >= 0)
 650:	14fd                	addi	s1,s1,-1
 652:	ff2498e3          	bne	s1,s2,642 <printint+0x8c>
}
 656:	70e2                	ld	ra,56(sp)
 658:	7442                	ld	s0,48(sp)
 65a:	74a2                	ld	s1,40(sp)
 65c:	7902                	ld	s2,32(sp)
 65e:	69e2                	ld	s3,24(sp)
 660:	6121                	addi	sp,sp,64
 662:	8082                	ret

0000000000000664 <vprintf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
vprintf(int fd, const char *fmt, va_list ap)
{
 664:	7119                	addi	sp,sp,-128
 666:	fc86                	sd	ra,120(sp)
 668:	f8a2                	sd	s0,112(sp)
 66a:	f4a6                	sd	s1,104(sp)
 66c:	f0ca                	sd	s2,96(sp)
 66e:	ecce                	sd	s3,88(sp)
 670:	e8d2                	sd	s4,80(sp)
 672:	e4d6                	sd	s5,72(sp)
 674:	e0da                	sd	s6,64(sp)
 676:	fc5e                	sd	s7,56(sp)
 678:	f862                	sd	s8,48(sp)
 67a:	f466                	sd	s9,40(sp)
 67c:	f06a                	sd	s10,32(sp)
 67e:	ec6e                	sd	s11,24(sp)
 680:	0100                	addi	s0,sp,128
  char *s;
  int c, i, state;

  state = 0;
  for(i = 0; fmt[i]; i++){
 682:	0005c483          	lbu	s1,0(a1)
 686:	18048d63          	beqz	s1,820 <vprintf+0x1bc>
 68a:	8aaa                	mv	s5,a0
 68c:	8b32                	mv	s6,a2
 68e:	00158913          	addi	s2,a1,1
  state = 0;
 692:	4981                	li	s3,0
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 694:	02500a13          	li	s4,37
      if(c == 'd'){
 698:	06400c13          	li	s8,100
        printint(fd, va_arg(ap, int), 10, 1);
      } else if(c == 'l') {
 69c:	06c00c93          	li	s9,108
        printint(fd, va_arg(ap, uint64), 10, 0);
      } else if(c == 'x') {
 6a0:	07800d13          	li	s10,120
        printint(fd, va_arg(ap, int), 16, 0);
      } else if(c == 'p') {
 6a4:	07000d93          	li	s11,112
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 6a8:	00000b97          	auipc	s7,0x0
 6ac:	460b8b93          	addi	s7,s7,1120 # b08 <digits>
 6b0:	a839                	j	6ce <vprintf+0x6a>
        putc(fd, c);
 6b2:	85a6                	mv	a1,s1
 6b4:	8556                	mv	a0,s5
 6b6:	00000097          	auipc	ra,0x0
 6ba:	ede080e7          	jalr	-290(ra) # 594 <putc>
 6be:	a019                	j	6c4 <vprintf+0x60>
    } else if(state == '%'){
 6c0:	01498f63          	beq	s3,s4,6de <vprintf+0x7a>
  for(i = 0; fmt[i]; i++){
 6c4:	0905                	addi	s2,s2,1
 6c6:	fff94483          	lbu	s1,-1(s2)
 6ca:	14048b63          	beqz	s1,820 <vprintf+0x1bc>
    c = fmt[i] & 0xff;
 6ce:	0004879b          	sext.w	a5,s1
    if(state == 0){
 6d2:	fe0997e3          	bnez	s3,6c0 <vprintf+0x5c>
      if(c == '%'){
 6d6:	fd479ee3          	bne	a5,s4,6b2 <vprintf+0x4e>
        state = '%';
 6da:	89be                	mv	s3,a5
 6dc:	b7e5                	j	6c4 <vprintf+0x60>
      if(c == 'd'){
 6de:	05878063          	beq	a5,s8,71e <vprintf+0xba>
      } else if(c == 'l') {
 6e2:	05978c63          	beq	a5,s9,73a <vprintf+0xd6>
      } else if(c == 'x') {
 6e6:	07a78863          	beq	a5,s10,756 <vprintf+0xf2>
      } else if(c == 'p') {
 6ea:	09b78463          	beq	a5,s11,772 <vprintf+0x10e>
        printptr(fd, va_arg(ap, uint64));
      } else if(c == 's'){
 6ee:	07300713          	li	a4,115
 6f2:	0ce78563          	beq	a5,a4,7bc <vprintf+0x158>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 6f6:	06300713          	li	a4,99
 6fa:	0ee78c63          	beq	a5,a4,7f2 <vprintf+0x18e>
        putc(fd, va_arg(ap, uint));
      } else if(c == '%'){
 6fe:	11478663          	beq	a5,s4,80a <vprintf+0x1a6>
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
 702:	85d2                	mv	a1,s4
 704:	8556                	mv	a0,s5
 706:	00000097          	auipc	ra,0x0
 70a:	e8e080e7          	jalr	-370(ra) # 594 <putc>
        putc(fd, c);
 70e:	85a6                	mv	a1,s1
 710:	8556                	mv	a0,s5
 712:	00000097          	auipc	ra,0x0
 716:	e82080e7          	jalr	-382(ra) # 594 <putc>
      }
      state = 0;
 71a:	4981                	li	s3,0
 71c:	b765                	j	6c4 <vprintf+0x60>
        printint(fd, va_arg(ap, int), 10, 1);
 71e:	008b0493          	addi	s1,s6,8
 722:	4685                	li	a3,1
 724:	4629                	li	a2,10
 726:	000b2583          	lw	a1,0(s6)
 72a:	8556                	mv	a0,s5
 72c:	00000097          	auipc	ra,0x0
 730:	e8a080e7          	jalr	-374(ra) # 5b6 <printint>
 734:	8b26                	mv	s6,s1
      state = 0;
 736:	4981                	li	s3,0
 738:	b771                	j	6c4 <vprintf+0x60>
        printint(fd, va_arg(ap, uint64), 10, 0);
 73a:	008b0493          	addi	s1,s6,8
 73e:	4681                	li	a3,0
 740:	4629                	li	a2,10
 742:	000b2583          	lw	a1,0(s6)
 746:	8556                	mv	a0,s5
 748:	00000097          	auipc	ra,0x0
 74c:	e6e080e7          	jalr	-402(ra) # 5b6 <printint>
 750:	8b26                	mv	s6,s1
      state = 0;
 752:	4981                	li	s3,0
 754:	bf85                	j	6c4 <vprintf+0x60>
        printint(fd, va_arg(ap, int), 16, 0);
 756:	008b0493          	addi	s1,s6,8
 75a:	4681                	li	a3,0
 75c:	4641                	li	a2,16
 75e:	000b2583          	lw	a1,0(s6)
 762:	8556                	mv	a0,s5
 764:	00000097          	auipc	ra,0x0
 768:	e52080e7          	jalr	-430(ra) # 5b6 <printint>
 76c:	8b26                	mv	s6,s1
      state = 0;
 76e:	4981                	li	s3,0
 770:	bf91                	j	6c4 <vprintf+0x60>
        printptr(fd, va_arg(ap, uint64));
 772:	008b0793          	addi	a5,s6,8
 776:	f8f43423          	sd	a5,-120(s0)
 77a:	000b3983          	ld	s3,0(s6)
  putc(fd, '0');
 77e:	03000593          	li	a1,48
 782:	8556                	mv	a0,s5
 784:	00000097          	auipc	ra,0x0
 788:	e10080e7          	jalr	-496(ra) # 594 <putc>
  putc(fd, 'x');
 78c:	85ea                	mv	a1,s10
 78e:	8556                	mv	a0,s5
 790:	00000097          	auipc	ra,0x0
 794:	e04080e7          	jalr	-508(ra) # 594 <putc>
 798:	44c1                	li	s1,16
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 79a:	03c9d793          	srli	a5,s3,0x3c
 79e:	97de                	add	a5,a5,s7
 7a0:	0007c583          	lbu	a1,0(a5)
 7a4:	8556                	mv	a0,s5
 7a6:	00000097          	auipc	ra,0x0
 7aa:	dee080e7          	jalr	-530(ra) # 594 <putc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
 7ae:	0992                	slli	s3,s3,0x4
 7b0:	34fd                	addiw	s1,s1,-1
 7b2:	f4e5                	bnez	s1,79a <vprintf+0x136>
        printptr(fd, va_arg(ap, uint64));
 7b4:	f8843b03          	ld	s6,-120(s0)
      state = 0;
 7b8:	4981                	li	s3,0
 7ba:	b729                	j	6c4 <vprintf+0x60>
        s = va_arg(ap, char*);
 7bc:	008b0993          	addi	s3,s6,8
 7c0:	000b3483          	ld	s1,0(s6)
        if(s == 0)
 7c4:	c085                	beqz	s1,7e4 <vprintf+0x180>
        while(*s != 0){
 7c6:	0004c583          	lbu	a1,0(s1)
 7ca:	c9a1                	beqz	a1,81a <vprintf+0x1b6>
          putc(fd, *s);
 7cc:	8556                	mv	a0,s5
 7ce:	00000097          	auipc	ra,0x0
 7d2:	dc6080e7          	jalr	-570(ra) # 594 <putc>
          s++;
 7d6:	0485                	addi	s1,s1,1
        while(*s != 0){
 7d8:	0004c583          	lbu	a1,0(s1)
 7dc:	f9e5                	bnez	a1,7cc <vprintf+0x168>
        s = va_arg(ap, char*);
 7de:	8b4e                	mv	s6,s3
      state = 0;
 7e0:	4981                	li	s3,0
 7e2:	b5cd                	j	6c4 <vprintf+0x60>
          s = "(null)";
 7e4:	00000497          	auipc	s1,0x0
 7e8:	33c48493          	addi	s1,s1,828 # b20 <digits+0x18>
        while(*s != 0){
 7ec:	02800593          	li	a1,40
 7f0:	bff1                	j	7cc <vprintf+0x168>
        putc(fd, va_arg(ap, uint));
 7f2:	008b0493          	addi	s1,s6,8
 7f6:	000b4583          	lbu	a1,0(s6)
 7fa:	8556                	mv	a0,s5
 7fc:	00000097          	auipc	ra,0x0
 800:	d98080e7          	jalr	-616(ra) # 594 <putc>
 804:	8b26                	mv	s6,s1
      state = 0;
 806:	4981                	li	s3,0
 808:	bd75                	j	6c4 <vprintf+0x60>
        putc(fd, c);
 80a:	85d2                	mv	a1,s4
 80c:	8556                	mv	a0,s5
 80e:	00000097          	auipc	ra,0x0
 812:	d86080e7          	jalr	-634(ra) # 594 <putc>
      state = 0;
 816:	4981                	li	s3,0
 818:	b575                	j	6c4 <vprintf+0x60>
        s = va_arg(ap, char*);
 81a:	8b4e                	mv	s6,s3
      state = 0;
 81c:	4981                	li	s3,0
 81e:	b55d                	j	6c4 <vprintf+0x60>
    }
  }
}
 820:	70e6                	ld	ra,120(sp)
 822:	7446                	ld	s0,112(sp)
 824:	74a6                	ld	s1,104(sp)
 826:	7906                	ld	s2,96(sp)
 828:	69e6                	ld	s3,88(sp)
 82a:	6a46                	ld	s4,80(sp)
 82c:	6aa6                	ld	s5,72(sp)
 82e:	6b06                	ld	s6,64(sp)
 830:	7be2                	ld	s7,56(sp)
 832:	7c42                	ld	s8,48(sp)
 834:	7ca2                	ld	s9,40(sp)
 836:	7d02                	ld	s10,32(sp)
 838:	6de2                	ld	s11,24(sp)
 83a:	6109                	addi	sp,sp,128
 83c:	8082                	ret

000000000000083e <fprintf>:

void
fprintf(int fd, const char *fmt, ...)
{
 83e:	715d                	addi	sp,sp,-80
 840:	ec06                	sd	ra,24(sp)
 842:	e822                	sd	s0,16(sp)
 844:	1000                	addi	s0,sp,32
 846:	e010                	sd	a2,0(s0)
 848:	e414                	sd	a3,8(s0)
 84a:	e818                	sd	a4,16(s0)
 84c:	ec1c                	sd	a5,24(s0)
 84e:	03043023          	sd	a6,32(s0)
 852:	03143423          	sd	a7,40(s0)
  va_list ap;

  va_start(ap, fmt);
 856:	fe843423          	sd	s0,-24(s0)
  vprintf(fd, fmt, ap);
 85a:	8622                	mv	a2,s0
 85c:	00000097          	auipc	ra,0x0
 860:	e08080e7          	jalr	-504(ra) # 664 <vprintf>
}
 864:	60e2                	ld	ra,24(sp)
 866:	6442                	ld	s0,16(sp)
 868:	6161                	addi	sp,sp,80
 86a:	8082                	ret

000000000000086c <printf>:

void
printf(const char *fmt, ...)
{
 86c:	711d                	addi	sp,sp,-96
 86e:	ec06                	sd	ra,24(sp)
 870:	e822                	sd	s0,16(sp)
 872:	1000                	addi	s0,sp,32
 874:	e40c                	sd	a1,8(s0)
 876:	e810                	sd	a2,16(s0)
 878:	ec14                	sd	a3,24(s0)
 87a:	f018                	sd	a4,32(s0)
 87c:	f41c                	sd	a5,40(s0)
 87e:	03043823          	sd	a6,48(s0)
 882:	03143c23          	sd	a7,56(s0)
  va_list ap;

  va_start(ap, fmt);
 886:	00840613          	addi	a2,s0,8
 88a:	fec43423          	sd	a2,-24(s0)
  vprintf(1, fmt, ap);
 88e:	85aa                	mv	a1,a0
 890:	4505                	li	a0,1
 892:	00000097          	auipc	ra,0x0
 896:	dd2080e7          	jalr	-558(ra) # 664 <vprintf>
}
 89a:	60e2                	ld	ra,24(sp)
 89c:	6442                	ld	s0,16(sp)
 89e:	6125                	addi	sp,sp,96
 8a0:	8082                	ret

00000000000008a2 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 8a2:	1141                	addi	sp,sp,-16
 8a4:	e422                	sd	s0,8(sp)
 8a6:	0800                	addi	s0,sp,16
  Header *bp, *p;

  bp = (Header*)ap - 1;
 8a8:	ff050693          	addi	a3,a0,-16
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 8ac:	00000797          	auipc	a5,0x0
 8b0:	27c78793          	addi	a5,a5,636 # b28 <__bss_start>
 8b4:	639c                	ld	a5,0(a5)
 8b6:	a805                	j	8e6 <free+0x44>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
 8b8:	4618                	lw	a4,8(a2)
 8ba:	9db9                	addw	a1,a1,a4
 8bc:	feb52c23          	sw	a1,-8(a0)
    bp->s.ptr = p->s.ptr->s.ptr;
 8c0:	6398                	ld	a4,0(a5)
 8c2:	6318                	ld	a4,0(a4)
 8c4:	fee53823          	sd	a4,-16(a0)
 8c8:	a091                	j	90c <free+0x6a>
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
 8ca:	ff852703          	lw	a4,-8(a0)
 8ce:	9e39                	addw	a2,a2,a4
 8d0:	c790                	sw	a2,8(a5)
    p->s.ptr = bp->s.ptr;
 8d2:	ff053703          	ld	a4,-16(a0)
 8d6:	e398                	sd	a4,0(a5)
 8d8:	a099                	j	91e <free+0x7c>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 8da:	6398                	ld	a4,0(a5)
 8dc:	00e7e463          	bltu	a5,a4,8e4 <free+0x42>
 8e0:	00e6ea63          	bltu	a3,a4,8f4 <free+0x52>
{
 8e4:	87ba                	mv	a5,a4
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 8e6:	fed7fae3          	bleu	a3,a5,8da <free+0x38>
 8ea:	6398                	ld	a4,0(a5)
 8ec:	00e6e463          	bltu	a3,a4,8f4 <free+0x52>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 8f0:	fee7eae3          	bltu	a5,a4,8e4 <free+0x42>
  if(bp + bp->s.size == p->s.ptr){
 8f4:	ff852583          	lw	a1,-8(a0)
 8f8:	6390                	ld	a2,0(a5)
 8fa:	02059713          	slli	a4,a1,0x20
 8fe:	9301                	srli	a4,a4,0x20
 900:	0712                	slli	a4,a4,0x4
 902:	9736                	add	a4,a4,a3
 904:	fae60ae3          	beq	a2,a4,8b8 <free+0x16>
    bp->s.ptr = p->s.ptr;
 908:	fec53823          	sd	a2,-16(a0)
  if(p + p->s.size == bp){
 90c:	4790                	lw	a2,8(a5)
 90e:	02061713          	slli	a4,a2,0x20
 912:	9301                	srli	a4,a4,0x20
 914:	0712                	slli	a4,a4,0x4
 916:	973e                	add	a4,a4,a5
 918:	fae689e3          	beq	a3,a4,8ca <free+0x28>
  } else
    p->s.ptr = bp;
 91c:	e394                	sd	a3,0(a5)
  freep = p;
 91e:	00000717          	auipc	a4,0x0
 922:	20f73523          	sd	a5,522(a4) # b28 <__bss_start>
}
 926:	6422                	ld	s0,8(sp)
 928:	0141                	addi	sp,sp,16
 92a:	8082                	ret

000000000000092c <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
 92c:	7139                	addi	sp,sp,-64
 92e:	fc06                	sd	ra,56(sp)
 930:	f822                	sd	s0,48(sp)
 932:	f426                	sd	s1,40(sp)
 934:	f04a                	sd	s2,32(sp)
 936:	ec4e                	sd	s3,24(sp)
 938:	e852                	sd	s4,16(sp)
 93a:	e456                	sd	s5,8(sp)
 93c:	e05a                	sd	s6,0(sp)
 93e:	0080                	addi	s0,sp,64
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 940:	02051993          	slli	s3,a0,0x20
 944:	0209d993          	srli	s3,s3,0x20
 948:	09bd                	addi	s3,s3,15
 94a:	0049d993          	srli	s3,s3,0x4
 94e:	2985                	addiw	s3,s3,1
 950:	0009891b          	sext.w	s2,s3
  if((prevp = freep) == 0){
 954:	00000797          	auipc	a5,0x0
 958:	1d478793          	addi	a5,a5,468 # b28 <__bss_start>
 95c:	6388                	ld	a0,0(a5)
 95e:	c515                	beqz	a0,98a <malloc+0x5e>
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 960:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 962:	4798                	lw	a4,8(a5)
 964:	03277f63          	bleu	s2,a4,9a2 <malloc+0x76>
 968:	8a4e                	mv	s4,s3
 96a:	0009871b          	sext.w	a4,s3
 96e:	6685                	lui	a3,0x1
 970:	00d77363          	bleu	a3,a4,976 <malloc+0x4a>
 974:	6a05                	lui	s4,0x1
 976:	000a0a9b          	sext.w	s5,s4
  p = sbrk(nu * sizeof(Header));
 97a:	004a1a1b          	slliw	s4,s4,0x4
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*)(p + 1);
    }
    if(p == freep)
 97e:	00000497          	auipc	s1,0x0
 982:	1aa48493          	addi	s1,s1,426 # b28 <__bss_start>
  if(p == (char*)-1)
 986:	5b7d                	li	s6,-1
 988:	a885                	j	9f8 <malloc+0xcc>
    base.s.ptr = freep = prevp = &base;
 98a:	00000797          	auipc	a5,0x0
 98e:	1a678793          	addi	a5,a5,422 # b30 <base>
 992:	00000717          	auipc	a4,0x0
 996:	18f73b23          	sd	a5,406(a4) # b28 <__bss_start>
 99a:	e39c                	sd	a5,0(a5)
    base.s.size = 0;
 99c:	0007a423          	sw	zero,8(a5)
    if(p->s.size >= nunits){
 9a0:	b7e1                	j	968 <malloc+0x3c>
      if(p->s.size == nunits)
 9a2:	02e90b63          	beq	s2,a4,9d8 <malloc+0xac>
        p->s.size -= nunits;
 9a6:	4137073b          	subw	a4,a4,s3
 9aa:	c798                	sw	a4,8(a5)
        p += p->s.size;
 9ac:	1702                	slli	a4,a4,0x20
 9ae:	9301                	srli	a4,a4,0x20
 9b0:	0712                	slli	a4,a4,0x4
 9b2:	97ba                	add	a5,a5,a4
        p->s.size = nunits;
 9b4:	0137a423          	sw	s3,8(a5)
      freep = prevp;
 9b8:	00000717          	auipc	a4,0x0
 9bc:	16a73823          	sd	a0,368(a4) # b28 <__bss_start>
      return (void*)(p + 1);
 9c0:	01078513          	addi	a0,a5,16
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 9c4:	70e2                	ld	ra,56(sp)
 9c6:	7442                	ld	s0,48(sp)
 9c8:	74a2                	ld	s1,40(sp)
 9ca:	7902                	ld	s2,32(sp)
 9cc:	69e2                	ld	s3,24(sp)
 9ce:	6a42                	ld	s4,16(sp)
 9d0:	6aa2                	ld	s5,8(sp)
 9d2:	6b02                	ld	s6,0(sp)
 9d4:	6121                	addi	sp,sp,64
 9d6:	8082                	ret
        prevp->s.ptr = p->s.ptr;
 9d8:	6398                	ld	a4,0(a5)
 9da:	e118                	sd	a4,0(a0)
 9dc:	bff1                	j	9b8 <malloc+0x8c>
  hp->s.size = nu;
 9de:	01552423          	sw	s5,8(a0)
  free((void*)(hp + 1));
 9e2:	0541                	addi	a0,a0,16
 9e4:	00000097          	auipc	ra,0x0
 9e8:	ebe080e7          	jalr	-322(ra) # 8a2 <free>
  return freep;
 9ec:	6088                	ld	a0,0(s1)
      if((p = morecore(nunits)) == 0)
 9ee:	d979                	beqz	a0,9c4 <malloc+0x98>
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 9f0:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 9f2:	4798                	lw	a4,8(a5)
 9f4:	fb2777e3          	bleu	s2,a4,9a2 <malloc+0x76>
    if(p == freep)
 9f8:	6098                	ld	a4,0(s1)
 9fa:	853e                	mv	a0,a5
 9fc:	fef71ae3          	bne	a4,a5,9f0 <malloc+0xc4>
  p = sbrk(nu * sizeof(Header));
 a00:	8552                	mv	a0,s4
 a02:	00000097          	auipc	ra,0x0
 a06:	b72080e7          	jalr	-1166(ra) # 574 <sbrk>
  if(p == (char*)-1)
 a0a:	fd651ae3          	bne	a0,s6,9de <malloc+0xb2>
        return 0;
 a0e:	4501                	li	a0,0
 a10:	bf55                	j	9c4 <malloc+0x98>
